Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipaddr.js

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipaddr.js

A library for manipulating IPv4 and IPv6 addresses in JavaScript.

  • 1.9.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35M
decreased by-16.94%
Maintainers
1
Weekly downloads
 
Created

What is ipaddr.js?

The ipaddr.js package is a library for manipulating IPv4 and IPv6 addresses in JavaScript. It allows for parsing, validating, and normalizing IP addresses, as well as performing operations like determining if an IP is in a particular subnet.

What are ipaddr.js's main functionalities?

Parsing and Validating IP Addresses

This feature allows you to parse a string representation of an IP address into an ipaddr.js object and validate if a given string is a valid IP address.

const ipaddr = require('ipaddr.js');

const addr = ipaddr.parse('192.168.1.1');
const isValid = ipaddr.isValid('192.168.1.1');

Determining IP Address Type

This feature helps in determining whether a parsed IP address is of type IPv4 or IPv6.

const ipaddr = require('ipaddr.js');

const addr = ipaddr.parse('192.168.1.1');
const isIPv4 = addr.kind() === 'ipv4';
const isIPv6 = addr.kind() === 'ipv6';

Subnet Matching

This feature is used to check if an IP address belongs to a certain subnet.

const ipaddr = require('ipaddr.js');

const addr = ipaddr.parse('192.168.1.1');
const range = ipaddr.parse('192.168.1.0/24');
const isInSubnet = addr.match(range);

Range Checking

This feature allows you to check the range of an IP address, such as whether it's unicast, multicast, link-local, private, etc.

const ipaddr = require('ipaddr.js');

const addr = ipaddr.parse('2001:db8::1');
const isReserved = addr.range() === 'unicast';

Other packages similar to ipaddr.js

Keywords

FAQs

Package last updated on 17 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc